package com.demo.Servlet;

import com.demo.dao.HeroDAO;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet(name = "HeroDeleteServlet",urlPatterns = "/HeroDeleteServlet")
public class HeroDeleteServlet extends HttpServlet {

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		int id = Integer.parseInt(request.getParameter("id"));
		
		new HeroDAO().delete(id);

		response.sendRedirect("./HeroListServlet");
		
	}
}
